//
//  SinaWeiboLogInController.m
//  ios_51job
//
//  Created by kai ren on 27/09/2011.
//  Copyright 2011 none. All rights reserved.
//

#import "SinaWeiboLogInController.h"


@implementation SinaWeiboLogInController

#pragma mark -
#pragma mark other

- (id)initWithDeleget:(NSObject<LogInControllerDelegate> *)object {
	if (self = [super initWithDeleget:object]) {
		tokenUrl = [[NSString alloc] initWithString:SinaTokenUrl];
		verifyUrl = [[NSString alloc] initWithString:SinaVerifyUrl];
		accessUrl = [[NSString alloc] initWithString:SinaAccessUrl];
		cacheName = [[NSString alloc] initWithString:SINA_OAUTH_CACHE];
		
		appKey = [[NSString alloc] initWithString:SinaAppKey];
		appSecret = [[NSString alloc] initWithString:SinaAppSecret];
	}
	
	return self;
}

#pragma mark -
#pragma mark NSURLConnection delegate

/** Delegate: Call when Receive a new Response, Maybe called serveral times **/
- (void)connection:(NSURLConnection *)conn didReceiveResponse:(NSURLResponse *)response{
	[self resetData];
	
    /** Get response code **/
    NSHTTPURLResponse *resp = (NSHTTPURLResponse *)response;
    int statusCode = [resp statusCode];
	
	NSLog(@"DEHttpConn:didReceiveResponse => HttpCode: %d.", statusCode);
	
	if (statusCode >= 403) {
		
	} else if (statusCode == 304) {
		
        [conn cancel];
    }
}

@end

